package com.luokun.vue_shop.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.luokun.vue_shop.entity.SpManager;
import com.luokun.vue_shop.mapper.SpManagerMapper;
import com.luokun.vue_shop.model.SpManagerModel;
import com.luokun.vue_shop.model.SpPermissionApiModel;
import com.luokun.vue_shop.service.ISpManagerService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SpManagerServiceImpl extends ServiceImpl<SpManagerMapper, SpManager> implements ISpManagerService {
    @Resource
    private SpManagerMapper spManagerMapper;

    @Override
    public IPage<SpManagerModel> getSpManager(Integer pageNo,Integer pageSize, String mgName) {
        try {
            Page<SpManagerModel> p = new Page<>(pageNo, pageSize);
            p.setRecords(spManagerMapper.getSpManager(p,mgName));
            return p;
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage());
        }

    }

    @Override
    public Integer getcount(String mgName) {

        return spManagerMapper.getcount(mgName);

    }


    @Override
    public Integer updSpManager(Integer mgId, Integer mgState) {
        return spManagerMapper.updSpManager(mgId,mgState);
    }

    @Override
    public List<SpPermissionApiModel> getRightsList() {
        return spManagerMapper.getRightsList();
    }


}
